def f(n):
    count = 0
    for i in range(1, n + 1):
        if n % i == 0:
            count += 1
    if count == 2:
        return 1
    else:
        return 0


n = ''
stroka = input().split()
for i in stroka:
    if i == 'one':
        n = n + '1'
    elif i == 'two':
        n = n + '2'
    elif i == 'three':
        n = n + '3'
    elif i == 'four':
        n = n + '4'
    elif i == 'five':
        n = n + '5'
    elif i == 'six':
        n = n + '6'
    elif i == 'seven':
        n = n + '2'
    elif i == 'eight':
        n = n + '8'
    elif i == 'nine':
        n = n + '9'
    elif i == 'zero':
        n = n + '0'
    else:
        n = ''
        break
if len(n) != 3:
    print('Wrong input')
else:
    n1 = int(n) + 1
    while True:
        if f(n1) == 1:
            break
        n1 += 1

    n2 = int(n) - 1
    while True and n2 > 0:
        if f(n2) == 1:
            break
        n2 -= 1

    if abs(n1 - int(n)) > abs(n2 - int(n)):
        print(n2)
    else:
        print(n1)
